using PKGames.Analytics;

namespace PKGames.Voxel.Analytics
{
	public class BlockInteractionEvent : AnalyticsEvent
	{
		private readonly string _blockType;

		private int _blocksAdded;

		private int _blocksRemoved;

		private const string EventName = "block_interaction";

		private const string BlockTypeKey = "blockType";

		private const string AddedKey = "added";

		private const string RemovedKey = "removed";

		private const string LevelNameKey = "levelName";

		private const int EventRevision = 0;

		protected override int Flags => 3;

		protected override string Name => "block_interaction";

		protected override int Revision => 0;

		public BlockInteractionEvent(string levelName, string blockType)
		{
			_blockType = blockType;
			base.Parameters["levelName"] = new UnityEncodedPrimitiveData(levelName);
		}

		public void BlocksAdded(int count)
		{
			_blocksAdded += count;
		}

		public void BlocksRemoved(int count)
		{
			_blocksRemoved += count;
		}

		public override void Finish()
		{
			base.Parameters["added"] = new UnityEncodedPrimitiveData(_blocksAdded);
			base.Parameters["removed"] = new UnityEncodedPrimitiveData(_blocksRemoved);
			base.Parameters["blockType"] = new UnityEncodedPrimitiveData(_blockType);
		}
	}
}
